package io.renren.modules.media.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.media.entity.MediaJobInfoEntity;
import io.renren.modules.media.model.MediaCapturePictureJobReq;
import io.renren.modules.media.model.MediaCutJobReq;
import io.renren.modules.media.model.MediaRecordJobReq;
import io.renren.modules.media.model.MediaSplicingJobReq;
import io.renren.modules.media.service.MediaJobInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author zctel
 * @email 845990668@qq.com
 * @date 2021-10-16 15:59:18
 */
@RestController
@RequestMapping("meida/mediajobinfo")
public class MediaJobInfoController {
    @Autowired
    private MediaJobInfoService mediaJobInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("meida:mediajobinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mediaJobInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("meida:mediajobinfo:info")
    public R info(@PathVariable("id") Integer id){
		MediaJobInfoEntity mediaJobInfo = mediaJobInfoService.getById(id);

        return R.ok().put("mediaJobInfo", mediaJobInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("meida:mediajobinfo:save")
    public R save(@RequestBody MediaJobInfoEntity mediaJobInfo){
		mediaJobInfoService.save(mediaJobInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("meida:mediajobinfo:update")
    public R update(@RequestBody MediaJobInfoEntity mediaJobInfo){
		mediaJobInfoService.updateById(mediaJobInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("meida:mediajobinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		mediaJobInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
    

    @RequestMapping("/record")
    //@RequiresPermissions("meida:mediajobinfo:save")
    public R record(@RequestBody MediaRecordJobReq req){
    	new Thread(()->{
    		mediaJobInfoService.recordJob(req);
    	}).start();
        return R.ok();
    }
    
    @RequestMapping("/cut")
    public R cut(@RequestBody MediaCutJobReq req){
    	new Thread(()->{
    		mediaJobInfoService.cutJob(req);
    	}).start();
        return R.ok();
    }
    
    @RequestMapping("/splicing")
    public R splicing(@RequestBody MediaSplicingJobReq req){
    	new Thread(()->{
    		mediaJobInfoService.splicingJob(req);
    	}).start();
        return R.ok();
    }
    
    @RequestMapping("/capture")
    public R splicing(@RequestBody MediaCapturePictureJobReq req){
    	new Thread(()->{
    		mediaJobInfoService.capturePictureJob(req);
    	}).start();
        return R.ok();
    }

}
